package com.dixunzh.dianlailai.core.Controllers.Admin;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.dixunzh.dianlailai.core.Utils.RandomValidateCodeUtil;

import net.sf.json.JSONObject;

@RestController
@RequestMapping("/api/dexonzh-admin")
public class LoginController {
	
	@Autowired
	private RandomValidateCodeUtil randomvalidatecodeutil;
	@PostMapping("/chklogin")
	public JSONObject chkLogin() {
		JSONObject res = new JSONObject();
		res.put("msg", "success");
		return res;
	}
	@GetMapping("/getVerify")
	public void getVerify(HttpServletRequest request,HttpServletResponse response) {
		JSONObject res = new JSONObject();
		try {
			response.setContentType("images/jpeg");
			response.setHeader("Pragma", "No-cache");
			response.setHeader("Cache-Control", "no-cache");
			response.setDateHeader("Expire", 0);
			randomvalidatecodeutil.getRandcode(request, response);
		}catch(Exception ex) {
			ex.printStackTrace();
		}
	}
	
}
